<template>
	<div class="reflect-add">

		<div class="crumbs-link reflect-add-link clear">
			<em @click="goback()">教学反思</em>
			<strong><i>></i>{{name}}</strong>
			<el-button type="primary" class="fr" @click="saveLive()">发表</el-button>
		</div>

		<div class="reflect-add-cont">
			<el-input v-model.trim="nameInput" min="3" max="20" placeholder="请输入标题"></el-input>
			<vue-editor v-model.trim="profile" :editorToolbar="customToolbar" placeholder="请输入内容">
			</vue-editor>
		</div>
	</div>
</template>

<script>
import { VueEditor } from "vue2-editor";
export default {
  components: {
    VueEditor
  },
  data() {
    return {
      schedule_id: this.$route.query.id,
      name: this.$route.query.name,
      nameInput: "",
      profile: "",
      authority: "1",
      customToolbar: [
        [{ list: "ordered" }, { list: "bullet" }],
        [{ color: [] }, { background: [] }],
        ["clean"]
      ]
    };
  },
  methods: {
    goback() {
      this.$router.back(-1);
    },
    saveLive() {
      if(this.nameInput==""){
        this.$message.error("请输入标题哦~");
        return false;
      }
      if(this.profile==""){
        this.$message.error("请输入内容哦~");
        return false;
      }
      var params = {
        schedule_id: this.schedule_id,
        title: this.nameInput,
        content: this.profile
      };
      let success = data => {
        this.$message.success(data.msg);
        setTimeout(() => {
          this.$router.push({ path: "/course2/reflect" });
        }, 1000);
      };
      let fail = data => {};
      this.$ajax.post("api/teachingschedule/schedule_feedback", params, {
        func: { success: success, fail: fail }
      });
    }
  }
};
</script>